package com.atguigu.reflect;

public class Demo02GetClass {

    public static void main(String[] args) throws ClassNotFoundException {

        // 1、获取类的 Class 对象
        System.out.println(Demo02GetClass.class + " " + Demo02GetClass.class.hashCode());

        // 2、获取接口的 Class 对象
        System.out.println(Comparable.class);

        // 3、获取对象的运行时类型对应的 Class 对象
        Demo02GetClass demo = new Demo02GetClass();
        Class<? extends Demo02GetClass> demoClass = demo.getClass();
        System.out.println(demoClass + " " + demoClass.hashCode());

        // 4、根据全类名字符串获取对应的 Class 对象
        String fullClassName = "com.atguigu.reflect.Demo02GetClass";
        Class<?> demoClassByFullName = Class.forName(fullClassName);
        System.out.println(demoClassByFullName + " " + demoClassByFullName.hashCode());

        // 5、使用类加载器获取对应的 Class 对象
        Class<?> demoClassByLoader = ClassLoader.getSystemClassLoader().loadClass(fullClassName);
        System.out.println(demoClassByLoader + " " + demoClassByLoader.hashCode());
    }

}
